package org.kadicon.android.frameanimation;

import org.kadicon.android.frameanimation.R;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MyFrameAnim extends Activity {
	/** Called when the activity is first created. */

	AnimationDrawable androidAnimation;
	Button btn_start;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		btn_start = (Button) findViewById(R.id.start_anim);

		ImageView androidImage = (ImageView) findViewById(R.id.android_image);
		androidImage.setBackgroundResource(R.anim.frame);
		androidAnimation = (AnimationDrawable) androidImage.getBackground();

		btn_start.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if (androidAnimation.isRunning() == false) {
					btn_start.setText("stop");
					androidAnimation.start();
				} else {
					btn_start.setText("start");
					androidAnimation.stop();
				}
			}
		});
	}
}